package com.shuaqiu.simback.service;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import javax.inject.Named;
import javax.ws.rs.core.Response;
import javax.ws.rs.ext.ExceptionMapper;
import javax.ws.rs.ext.Provider;

/**
 * @author shuaqiu on 2013-10-19.
 */
@Provider
@Named
public class HeadStatusSupport implements ExceptionMapper<HeadStatusException> {


    private static final Log log = LogFactory.getLog(HeadStatusSupport.class);

    @Override
    public Response toResponse(HeadStatusException exception) {
        log.info(exception.getMessage());
        System.err.print(exception.getMessage());

        Response resp = Response.noContent().header("message",  exception.getMessage()).build();
        return resp;
    }
}
